﻿using System.Windows;
using System.Windows.Controls;

namespace ThunderboltCustomControlLibrary;

public class OptimizedTabControl:TabControl
{
	static OptimizedTabControl()
	{
		DefaultStyleKeyProperty.OverrideMetadata(typeof(OptimizedTabControl), new FrameworkPropertyMetadata(typeof(OptimizedTabControl)));
	}


	/// <summary>
	/// 方向枚举
	/// </summary>
	public enum OrientationEnum
	{
		Left,
		Right,
		Middle
	}




	public HorizontalAlignment TabHorizontalAlignment
	{
		get { return (HorizontalAlignment)GetValue(TabHorizontalAlignmentProperty); }
		set
		{
			SetValue(TabHorizontalAlignmentProperty, value);
		}
	}


	public static readonly DependencyProperty TabHorizontalAlignmentProperty =
		DependencyProperty.Register("TabHorizontalAlignment", typeof(HorizontalAlignment), typeof(OptimizedTabControl), new PropertyMetadata(HorizontalAlignment.Left, TabHorizontalAlignmentChanged));

	private static void TabHorizontalAlignmentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
	{
		object oldValue = (object)e.OldValue;
		object newValue = (object)e.NewValue;
		var OptimizedTabControl = (OptimizedTabControl)d;
		if (oldValue != newValue)
		{
			switch (newValue)
			{
				case HorizontalAlignment.Right:
					OptimizedTabControl.TabHorizontalAlignment = HorizontalAlignment.Right;
					break;
				case HorizontalAlignment.Center:
					OptimizedTabControl.TabHorizontalAlignment = HorizontalAlignment.Center;
					break;
				case HorizontalAlignment.Left:
					OptimizedTabControl.TabHorizontalAlignment = HorizontalAlignment.Left;
					break;
				default:
					break;
			}
		}
	}
}